/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.ce.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Jarik
 */
@Entity
@Table(name = "bankacc")
@NamedQueries({
    @NamedQuery(name = "Bankacc.findAll", query = "SELECT b FROM Bankacc b"),
    @NamedQuery(name = "Bankacc.findById", query = "SELECT b FROM Bankacc b WHERE b.id = :id"),
    @NamedQuery(name = "Bankacc.findByAccNum", query = "SELECT b FROM Bankacc b WHERE b.accNum = :accNum"),
    @NamedQuery(name = "Bankacc.findByBankName", query = "SELECT b FROM Bankacc b WHERE b.bankName = :bankName"),
    @NamedQuery(name = "Bankacc.findBySwift", query = "SELECT b FROM Bankacc b WHERE b.swift = :swift"),
//    @NamedQuery(name = "Bankacc.findByUserId", query = "SELECT b FROM Bankacc b WHERE b.user_id = :user_id"),
    @NamedQuery(name = "Bankacc.findByCorrespondentBank", query = "SELECT b FROM Bankacc b WHERE b.correspondentBank = :correspondentBank")})
public class Bankacc implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AccNum")
    private Integer accNum;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "BankName")
    private String bankName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 11)
    @Column(name = "SWIFT")
    private String swift;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "CorrespondentBank")
    private String correspondentBank;
    @JoinColumn(name = "User_id", referencedColumnName = "id")
    @ManyToOne(optional = false, cascade=CascadeType.MERGE)
    private User userid;
    @JoinColumn(name = "Currency", referencedColumnName = "ShortName")
    @OneToOne(optional = false, cascade=CascadeType.MERGE)
    private Currency currency;

    public Bankacc() {
    }

    public Bankacc(Integer id) {
        this.id = id;
    }

    public Bankacc(Integer id, int accNum, String bankName, String swift, String correspondentBank) {
        this.id = id;
        this.accNum = accNum;
        this.bankName = bankName;
        this.swift = swift;
        this.correspondentBank = correspondentBank;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAccNum() {
        return accNum;
    }

    public void setAccNum(Integer accNum) {
        this.accNum = accNum;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getSwift() {
        return swift;
    }

    public void setSwift(String swift) {
        this.swift = swift;
    }

    public String getCorrespondentBank() {
        return correspondentBank;
    }

    public void setCorrespondentBank(String correspondentBank) {
        this.correspondentBank = correspondentBank;
    }

    public User getUserid() {
        return userid;
    }

    public void setUserid(User userid) {
        this.userid = userid;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bankacc)) {
            return false;
        }
        Bankacc other = (Bankacc) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bionic.ce.entities.Bankacc[ id=" + id + " ]";
    }
    
}
